﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace MyUtils
{
    public class DDOLSingleton<T> : MonoBehaviour where T : DDOLSingleton<T>
    {

        protected static T _instance = null;

        public static T Instance
        {
            get
            {
                GameObject go = GameObject.Find("DDOL");

                if (null == go)
                {
                    go = new GameObject("DDOL");
                    DontDestroyOnLoad(go); //设置为不可销毁的
                }


                _instance = go.GetComponent<T>();

                if (null == _instance)
                {
                    _instance = go.AddComponent<T>();
                }

                return _instance;
            }
        }
    }
}

